package com.foreknow.demo12;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class SetDemo {
    public static void main(String[] args) {
        //1. 创建一个Set集合
        Set<Integer> set = new HashSet<>();
        //2. 向集合中添加元素
        set.add(1);
        set.add(2);
        set.add(2);
        set.add(3);
        //3.遍历集合
        Iterator<Integer> it = set.iterator();
        while (it.hasNext()) {
            Integer i = it.next();
            System.out.println(i);
        }

    }
}
